package com.mxpio.erp.equipment.controller;

import com.mxpio.erp.common.equipment.service.EquipmentReportService;
import com.mxpio.erp.common.equipment.vo.EquipmentReportVO;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "EquipmentReportController", description = "统计报表")
@RestController
@RequestMapping("/erp/equipment/report/")
public class EquipmentReportController {

    @Autowired
    private EquipmentReportService equipmentReportService;


    @GetMapping("wxgs")
    @Operation(summary = "维修工时统计", description = "维修工时统计", method = "GET")
    public Result<List<EquipmentReportVO>> wxgs(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getMaintenanceHours();
        return Result.OK(list);
    }

    @GetMapping("bygs")
    @Operation(summary = "保养工时统计", description = "保养工时统计", method = "GET")
    public Result<List<EquipmentReportVO>> bygs(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getUpkeepHours();
        return Result.OK(list);
    }

    @GetMapping("byjh")
    @Operation(summary = "保养计划达成率", description = "保养计划达成率", method = "GET")
    public Result<List<EquipmentReportVO>> byjh(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getUpkeepCompletionRate();
        return Result.OK(list);
    }

    @GetMapping("djjh")
    @Operation(summary = "点检计划达成率", description = "点检计划达成率", method = "GET")
    public Result<List<EquipmentReportVO>> djjh(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getCheckCompletionRate();
        return Result.OK(list);
    }

    @GetMapping("jhgd")
    @Operation(summary = "稽核工单达成率", description = "稽核工单达成率", method = "GET")
    public Result<List<EquipmentReportVO>> jhgd(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getAuditCompletionRate();
        return Result.OK(list);
    }

    @GetMapping("wxgd")
    @Operation(summary = "维修工单达成率", description = "维修工单达成率", method = "GET")
    public Result<List<EquipmentReportVO>> wxgd(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getRepairCompletionRate();
        return Result.OK(list);
    }

    @GetMapping("sbgz")
    @Operation(summary = "设备故障统计报表", description = "设备故障统计报表", method = "GET")
    public Result<List<EquipmentReportVO>> sbgz(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getEquipmentFailure();
        return Result.OK(list);
    }

    @GetMapping("sbzt")
    @Operation(summary = "设备状态看板", description = "设备状态看板", method = "GET")
    public Result<List<EquipmentReportVO>> sbzt(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getEquipmentStatus();
        return Result.OK(list);
    }

    @GetMapping("sbwhl")
    @Operation(summary = "设备完好率", description = "设备完好率", method = "GET")
    public Result<List<EquipmentReportVO>> sbwhl(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getEquipmentNormalStatus();
        return Result.OK(list);
    }

    @GetMapping("gztj")
    @Operation(summary = "设备故障次数统计", description = "设备故障次数统计", method = "GET")
    public Result<List<EquipmentReportVO>> gztj(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getEquipmentFailureCount();
        return Result.OK(list);
    }

    @GetMapping("mtbf")
    @Operation(summary = "平均故障前时间MTBF", description = "平均故障前时间MTBF", method = "GET")
    public Result<List<EquipmentReportVO>> mtbf(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getMeanTimeBeforeFailure();
        return Result.OK(list);
    }

    @GetMapping("mttr")
    @Operation(summary = "平均修复时间MTTR", description = "平均修复时间MTTR", method = "GET")
    public Result<List<EquipmentReportVO>> mttr(@Parameter(description="查询参数") Criteria criteria) {
        List<EquipmentReportVO> list = equipmentReportService.getMeanTimeToRepair();
        return Result.OK(list);
    }



}
